/**
 * 登录
 * @author Jaswine
 */
$(function () {
	//密码显示与保密
	$(".pwdSo3").click(function(){
		if($(this).attr("src")=="images/showpword.png"){
			$(".userpass1").val($(".userpass").val());
			$(".userpass").css("display","none");
			$(".userpass1").css("display","initial");
			$(this).attr("src","images/closspword.png");
		}else{
			$(".userpass").val($(".userpass1").val());
			$(".userpass").css("display","initial");
			$(".userpass1").css("display","none");
			$(this).attr("src","images/showpword.png");
		}
	})
	$(".userpass").blur(function(){
		$(".userpass1").val($(".userpass").val());
	})
	$(".userpass1").blur(function(){
		$(".userpass").val($(".userpass1").val());
	})
	
    $(".loginBtn").click(function () {
        $.ajax({
            url: requestUrl +"/app/user/login.do",
            type:"POST",
            data:{"phone":$.trim($(".username").val()),"password":$.trim($(".userpass").val())},
            dataType:"JSON",
            success:function (json) {
                /* 请求成功 */
                if (json.code==0){
                    window.localStorage.email = json.data.email;
                    window.localStorage.realName = json.data.realName;
                    window.localStorage.idNum = json.data.idNum;
                    window.localStorage.phone = json.data.mobile;
                    window.localStorage.userId = json.data.userId;
                    window.localStorage.userName = json.data.userName;
                    window.sessionStorage.token = json.data.token;
                    window.sessionStorage.papertype = json.data.papertype;
                    window.sessionStorage.paperno = json.data.paperno;
                    window.sessionStorage.customerNo = json.data.customerNo;
                    window.location.href="index.html";
                }else{
                alert(json.message);
                }
            }
        })
    })
});

